import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
//import fs from 'fs'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  const config = loadEnv(mode, './')
  return {
    base: './',
    plugins: [
      vue(),
    ],
    server: {
      host: '0.0.0.0',
      port: 5173,
      proxy: {
        [config.VITE_APP_BASE_PREFIX]: {
          target: config.VITE_APP_BASE_API,
          changeOrigin: true,
          rewrite: (path) =>
            path.replace(new RegExp(`^${config.VITE_APP_BASE_PREFIX}`), ''),
        },
      },

    },
  }
})
